﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TAM05
    {

        public TAM05()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VAMMODUL();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
        }

        public override void OnSave()
        {
            if (!IsSaved)
                return;
            if (dwMaster == null)
                return;
            TMV.UpdateAMMODUL(dwMaster, 0);
            string key = KEY;
            KEY = "";
            KEY = key;
            base.OnSave();
        }

        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length < 11)
                return;
            dwData = TBMain.NewRow(); 
            dwData["AMMMANDANT"] = app.Mandant;
            dwData["AMMNRKRS"] = "AND AMMNRKRS= '" + ORDERNUM.Substring(0, 2) + "'";
            dwData["AMMLFDNR"] = "AND AMMLFDNR= '" + ORDERNUM.Substring(2, 4) + "'";
            dwData["AMMPOS"] = "AND AMMPOS= '" + ORDERNUM.Substring(6, 2) + "'";
            dwData["AMMMODNR"] = "AND AMMMODNR= '" + ORDERNUM.Substring(8, 3) + "'";
            SResult = TMV.QAMD02(dwData);
            MergeData(SResult, true);
            base.LOADBYAUF();
        } 
        
    }
}
